function c=merge_vertical(a,b,div); 
% ================================================
% MERGE_VERTICAL 
%
%function c=merge_vertical(a,b,div); 
% Merge cells or matrices a and b divided by div (string) 
% Leave empty if do not wish to use 
% 
% A Justiniano Nov 27 2006 
% ===============================================
if isempty(b); error('Second cell input cannot be empty'); end; 
if ~iscell(b); b=num2cprec(b); end; 
if isempty(a);
    c=b
else 
    if nargin < 3 | isempty(div);
        nadd=0; 
    else
        nadd=1;
    end
    if ~iscell(a); a=num2cprec(a); end;
    na=size(a);nb=size(b); 
    nr=max(na(1),nb(1));
    nc=na(2)+nb(2)+nadd; 
    c=emptycell(nr,nc); 
    c(1:na(1),1:na(2))=a; 
    c(1:nb(1),na(2)+nadd+1:end)=b; 
    if nadd == 1; 
        if ~isstr(div); div=char(div); end; 
        c(:,na(2)+1)=fillcell(nr,1,div) 
    end 
end 